﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Persistence.Dao;
using Domain;
using Common;
namespace web
{
    public partial class productList : System.Web.UI.Page
    {
        int typeid = DNTRequest.GetQueryInt("typeid", 0);
        protected int count;
        protected void Page_Load(object sender, EventArgs e)
        {
            bindType();
            if (!IsPostBack)
            {
                bindProduct();
            }
        }
        private void bindType()
        {
            repTypeList.DataSource = new ProductTypeDao().GetModels("*", "1=1");
            repTypeList.DataBind();
        }
        private void bindProduct()
        {
            string condition = "";
            string order = string.Empty;
            if (typeid > 0)
            {
                condition = "producttype=" + typeid;
                order = "productShowOrder asc ,productid desc";
            }
            else
            {
                condition = "1=1";
                order = "productListOrder asc ,productid desc";
            }
            count = new ProductDao().GetCount(condition);
            repProductList.DataSource = new ProductDao().GetModels("*", condition, order, AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            repProductList.DataBind();
            AspNetPager1.RecordCount = count;
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            bindProduct();
        }
    }
}
